package com.zft.userwalletmanager.application.handler;

import com.zft.userwalletmanager.application.service.AccountFlowService;
import com.zft.userwalletmanager.application.service.WalletService;
import com.zft.userwalletmanager.domain.bo.WalletBO;
import com.zft.userwalletmanager.infrastructure.common.enums.ResultCode;
import com.zft.userwalletmanager.infrastructure.common.exception.BizException;
import com.zft.userwalletmanager.infrastructure.gateway.database.model.AccountFlowDO;
import com.zft.userwalletmanager.infrastructure.gateway.database.model.WalletDO;
import com.zft.userwalletmanager.web.response.AccountFlowDetailsResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class AccountFlowHandler {
    @Autowired
    private AccountFlowService accountFlowService;
    @Autowired
    private WalletService walletService;

    /**
     * 查找账务流水
     * @param walletBO
     * @return
     */
    public List<AccountFlowDO> selectAccountFlowDetails(WalletBO walletBO) {
        WalletDO walletDO = walletService.selectWalletByUserId(walletBO.getUserId(),false);
        if (Objects.isNull(walletDO)) {
            throw new BizException(ResultCode.WALLET_INFO_IS_NULL);
        }
        return accountFlowService.selectAccountFlowByWalletNo(walletDO.getWalletNo());
    }
}
